import linePoint from '@/assets/linePoint.png'
// 订单统计
export function getOrderCountLineOption(xAxisData, seriesData) {
  return {
    grid: {
      top: "13%",
      left: "3%",
      right: "3%",
      bottom: "2%",
      containLabel: true,
    },
    tooltip: {
      trigger: 'axis',
      textStyle: {
        fontSize: 13
      },
      axisPointer: {
        type: 'shadow',
        shadowStyle: {
          color: 'rgba(0,0,0,0.05)'
        }
      }
    },
    xAxis: {
      type: 'category',
      boundaryGap: false,
      axisLine: {
        lineStyle: {
          color: '#dddddd'
        }
      },
      axisTick: {
        show: false
      },
      splitLine: {
        show: false
      },
      axisLabel: {
        fontSize: 12,
        color: '#7F8189',
        formatter: function (value, index) {
          return value.slice(5, 10).replace('-', '/')
        }
      },
      data: xAxisData
    },
    yAxis: {
      name: '订单数量',
      type: 'value',
      nameTextStyle: {
        padding: [0,30,0,0]
      },
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      splitLine: {
        show: true,
        lineStyle: {
          color: '#dddddd'
        }
      },
      axisLabel: {
        fontSize: 12
      }
    },
    color: ['#1DAEFF', '#2EFF42', '#F29601', '#E50112', '#B96301', '#A2FFEC'],
    series: {
      name: '订单数',
      type: 'line',
      smooth: true,
      symbolSize: 18,
      symbol: 'image://' + linePoint,
      showSymbol: false,
      data: seriesData
    }
  }
}

// 订单
export function getMediaTypeOption(seriesData) {
  return {
    tooltip: {
      trigger: 'item',
      textStyle: {
        fontSize: 15
      },
      formatter: '{b}:{d}%'
    },
    legend: {
      top: '0%',
      right: '10%',
      itemWidth: 15,
      itemHeight: 15,
      itemGap: 15,
      icon: 'rect',
      textStyle: {
        fontSize: 12,
        padding: [0, 0, 0, 10]
      }
    },
    series: [{
      type: 'pie',
      center: ['50%', '55%'],
      radius: ['26%', '80%'],
      avoidLabelOverlap: false,
      z: -1,
      label: {
        show: true,
        position: 'inside',
        color: '#ffffff',
        fontSize: 13,
        formatter: '{c}\n{b}'
      },
      labelLine: {
        show: false
      },
      itemStyle: {
        borderRadius: 10,
        borderColor: '#fff',
        borderWidth: 2
      },
      data: seriesData
    }, 
    {
      type: "pie",
      center: ['50%', '55%'],
      radius: ['20%', '30%'],
      silent: true,
      label: {
        show:false
      },
      labelLine: {
        show: false
      },
      itemStyle: {
        color: 'rgba(243,159,32,.6)'
      },
      data: [100]
    }, 
    {
      type: "pie",
      center: ['50%', '55%'],
      radius: '20%',
      silent: true,
      label: {
        show:false
      },
      labelLine: {
        show: false
      },
      itemStyle: {
        color: 'rgba(243,159,32,1)'
      },
      data: [100]
    }
  ]
  }
}

// 销售统计
export function getSaleCountBarOption(arrList) {
  let xAxisData = []
  let seriesData = []
  arrList.forEach(item => {
    xAxisData.push(item.name)
    seriesData.push(item.value)
  })
  return {
    grid: {
      top: "13%",
      left: "3%",
      right: "3%",
      bottom: "2%",
      containLabel: true
    },
    tooltip : {
      trigger: 'axis',
      axisPointer: { 
        type: 'shadow'
      }
    },
    xAxis:  {
      type: 'category',
      axisLine: {
        lineStyle: {
          color: '#dddddd'
        }
      },
      axisTick: {
        show: false
      },
      splitLine: {
        show: false
      },
      axisLabel: {
        fontSize: 12,
        color: '#7F8189',
        formatter: function (value, index) {
          return value.slice(5, 10).replace('-', '/')
        }
      },
      data: xAxisData
    },
    yAxis: [{
      name: '销售额',
      type: 'value',
      nameTextStyle: {
        padding: [0,30,0,0]
      },
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      splitLine: {
        show: true,
        lineStyle: {
          color: '#dddddd'
        }
      },
      axisLabel: {
        fontSize: 12
      }
    }, {
      type: 'value',
      axisLine: {
        show: false
      },
      axisTick: {
        show: false
      },
      splitLine: {
        show: true,
        lineStyle: {
          color: '#dddddd'
        }
      },
      axisLabel: {
        fontSize: 12
      }
    }],
    series: [{
      name: '销售额',
      type: 'bar',
      barWidth: 45,
      label: {
        show: false
      },
      showBackground: true,
      backgroundStyle: {
        color: 'rgba(0,0,0,0.05)'
      },
      itemStyle: {
        borderRadius: [8,8,0,0],
        color: {
          x: 0,
          y: 0,
          x2: 0,
          y2: 1,
          type: 'linear',
          global: false,
          colorStops: [
            { offset: 0, color: '#F7E362' },
            { offset: 1, color: '#F29702' },
          ]
        },
      },
      data: seriesData
    }]
  }
}